package com.demo.game1;

import android.graphics.Bitmap;
import android.graphics.Canvas;

public class Ball {
	
	int x;
	int y;
	int yspeed;		
	boolean isDraw = false;
	GameView gameview;
	Bitmap bmp;
	
	public Ball(GameView gameview , Bitmap bm)
	{
		this.gameview = gameview;
		this.bmp = bm;		
		x = gameview.getWidth()/2;
		y = 30;
	}
	
	public void moveLR()
	{
		if(y <= 30)
		{
			yspeed = 30;
		}
			
		if(y + bmp.getHeight() >= gameview.getHeight())
		{
			yspeed = -30;
		}
		
		y += yspeed;
	}
	

	public void onDraw(Canvas canvas)
	{
		if(isDraw)
		{
			moveLR();
			canvas.drawBitmap(bmp, x, y, null);
		}
	}

}
